package Admin;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.sql.Date;

import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.xml.bind.ValidationEvent;
import javax.xml.bind.helpers.ValidationEventImpl;

import GroupClass.ConnectRMI;
import Project_etow.EtowInterface;

public class InsertAccount extends javax.swing.JDialog {

    private String                     checkvisable;
    private javax.swing.JButton        btcancel;
    private javax.swing.JButton        btreset;
    private javax.swing.JButton        btsubmit;
    private javax.swing.JComboBox      cbbgroup;
    private javax.swing.JComboBox      cbbnam;
    private javax.swing.JComboBox      cbbngay;
    private javax.swing.JComboBox      cbbsex;
    private javax.swing.JComboBox      cbbthang;
    private javax.swing.JLabel         jLabel1;
    private javax.swing.JLabel         lbaddress;
    private javax.swing.JLabel         lbage;
    private javax.swing.JLabel         lbcmnd;
    private javax.swing.JLabel         lbcompanyname;
    private javax.swing.JLabel         lbemail;
    private javax.swing.JLabel         lbgroupname;
    private javax.swing.JLabel         lbloginname;
    private javax.swing.JLabel         lbname;
    private javax.swing.JLabel         lbpassword;
    private javax.swing.JLabel         lbphone;
    private javax.swing.JLabel         lbsex;
    private javax.swing.JPasswordField pwcheck;
    private javax.swing.JPasswordField pwfile;
    private javax.swing.JTextField     ttcompanyname;
    private javax.swing.JTextField     txtaddress;
    private javax.swing.JTextField     txtcmnd;
    private javax.swing.JTextField     txtemail;
    private javax.swing.JTextField     txtloginname;
    private javax.swing.JTextField     txtname;
    private javax.swing.JTextField     txtphone;
    ConnectRMI connectRMI = new ConnectRMI();

    public String getCheckvisable() {
        return checkvisable;
    }

    public void setCheckvisable(String checkvisable) {
        this.checkvisable = checkvisable;
    }

    public InsertAccount(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    @SuppressWarnings("unchecked")
    private void initComponents() {

        txtemail = new javax.swing.JTextField();
        lbaddress = new javax.swing.JLabel();
        lbemail = new javax.swing.JLabel();
        lbsex = new javax.swing.JLabel();
        lbcmnd = new javax.swing.JLabel();
        ttcompanyname = new javax.swing.JTextField();
        txtloginname = new javax.swing.JTextField();
        txtname = new javax.swing.JTextField();
        lbloginname = new javax.swing.JLabel();
        lbname = new javax.swing.JLabel();
        txtcmnd = new javax.swing.JTextField();
        lbage = new javax.swing.JLabel();
        lbcompanyname = new javax.swing.JLabel();
        lbpassword = new javax.swing.JLabel();
        lbgroupname = new javax.swing.JLabel();
        txtaddress = new javax.swing.JTextField();
        lbphone = new javax.swing.JLabel();
        txtphone = new javax.swing.JTextField();
        btsubmit = new javax.swing.JButton();
        btcancel = new javax.swing.JButton();
        btreset = new javax.swing.JButton();
        pwfile = new javax.swing.JPasswordField();
        cbbngay = new javax.swing.JComboBox();
        cbbgroup = new javax.swing.JComboBox();
        cbbsex = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        pwcheck = new javax.swing.JPasswordField();
        cbbthang = new javax.swing.JComboBox();
        cbbnam = new javax.swing.JComboBox();

        setUndecorated(true);
        setLocation(350, 150);
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        lbaddress.setText("Address");

        lbemail.setText("Email");

        lbsex.setText("Sex");

        lbcmnd.setText("CMND");

        lbloginname.setText("LoginName");

        lbname.setText("Name");

        lbage.setText("BirthDay");

        lbcompanyname.setText("Companyname");

        lbpassword.setText("Password");

        lbgroupname.setText("GroupName");

        lbphone.setText("Phone");

        btsubmit.setText("Submit");

        btsubmit.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                try {

                    EtowInterface obj = null;
                    Registry registry = LocateRegistry.getRegistry(connectRMI.host, connectRMI.port);
                    obj = (EtowInterface) registry.lookup(connectRMI.regis);
                    int groupname = 0;
                    if (cbbgroup.getSelectedItem() == "Admin") {
                        groupname = 1;
                    } else {
                        groupname = 2;
                    }

                    String loginname = txtloginname.getText();
                    String password1 = pwfile.getText();
                    String checkpasss = pwcheck.getText();
                    String name = txtname.getText();
                    String company = ttcompanyname.getText();
                    Object x = cbbngay.getSelectedItem();
                    Object y = cbbthang.getSelectedItem();
                    Object z = cbbnam.getSelectedItem();
                    String age = z + "/" + y + "/" + x;
                    String sex = (String) cbbsex.getSelectedItem();
                    String cmnd = txtcmnd.getText();
                    String address = txtaddress.getText();
                    String phone = txtphone.getText();
                    String email = txtemail.getText();

                    if (cbbgroup.getSelectedItem() == "-----") {
                        JOptionPane.showMessageDialog(null, "Group Not Null");
                    } else if (loginname.length() == 0) {
                        JOptionPane.showMessageDialog(null, "LoginName Not Null");
                    } else if (password1.length() == 0) {
                        JOptionPane.showMessageDialog(null, "Password Not Null");
                    } else if (checkpasss.length() == 0) {
                        JOptionPane.showMessageDialog(null, "ConfimPassword Not Null");
                    } else if (password1.equals(checkpasss) != true) {
                        JOptionPane.showMessageDialog(null, "The password you entered do not match. Please try again.");
                    } else if (name.length() == 0) {
                        JOptionPane.showMessageDialog(null, "Name Not Null");
                    } else if (company.length() == 0) {
                        JOptionPane.showMessageDialog(null, "Company Not Null");
                    } else if (cbbngay.getSelectedItem() == "Day") {
                        JOptionPane.showMessageDialog(null, "Day Not Null");
                    } else if (cbbthang.getSelectedItem() == "Month") {
                        JOptionPane.showMessageDialog(null, "Month Not Null");
                    } else if (cbbnam.getSelectedItem() == "Year") {
                        JOptionPane.showMessageDialog(null, "Year Not Null");
                    } else if (cbbsex.getSelectedItem() == "-----") {
                        JOptionPane.showMessageDialog(null, "Year Not Null");
                    } else if (cmnd.length() == 0) {
                        JOptionPane.showMessageDialog(null, "CMND Not Null");
                    } else if (address.length() == 0) {
                        JOptionPane.showMessageDialog(null, "Address Not Null");
                    } else if (phone.length() == 0) {
                        JOptionPane.showMessageDialog(null, "Phone Not Null");
                    } else if (email.length() == 0) {
                        JOptionPane.showMessageDialog(null, "Email Not Null");
                    }

                    String result = obj.InsertAccount(groupname, loginname, password1, name, company, age, sex, cmnd,
                            address, phone, email);
                    if (cbbgroup.getSelectedItem() != "-----" && loginname.length() != 0 && password1.length() != 0
                            && checkpasss.length() != 0 && name.length() != 0 && company.length() != 0
                            && cbbngay.getSelectedItem() != "Day" && cbbthang.getSelectedItem() != "Month"
                            && cbbnam.getSelectedItem() != "Year" && cbbsex.getSelectedItem() != "-----"
                            && cmnd.length() != 0 && address.length() != 0 && phone.length() != 0
                            && email.length() != 0 && password1.equals(checkpasss) == true) {
                        if (result.equals("Insert")) {
                            obj.send(txtemail.getText(),"Your account is active." +"\n"+"UserName:" + txtloginname.getText()+"\n"+"Password:"+ password1);
                            JOptionPane.showMessageDialog(null, "Insert Successful");
                            setCheckvisable("close");
                            setVisible(false);

                        } else {
                            JOptionPane.showMessageDialog(null, "Insert Failed");
                        }
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        });

        btcancel.setText("Cancel");
        btcancel.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                setCheckvisable("close");
                setVisible(false);
            }
        });

        btreset.setText("Reset");

        cbbngay.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Day", "1", "2", "3", "4", "5", "6", "7",
                "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24",
                "25", "26", "27", "28", "29", "30", "31" }));

        cbbgroup.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-----", "Admin", "User" }));

        cbbsex.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-----", "Male", "Female"}));

        jLabel1.setText("ConfimPassword");

        cbbthang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Month", "1", "2", "3", "4", "5", "6",
                "7", "8", "9", "10", "11", "12", " " }));

        cbbnam.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Year", "2012", "2011", "2010", "2009",
                "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001", "2000", "1999", "1998", "1997", "1996",
                "1995", "1994", "1993", "1992", "1991", "1990", "1989", "1988", "1987", "1986", "1984", "1983", "1982",
                "1981", "1980", "1979", "1978", "1977", "1976", "1975", "1974", "1973", "1972", "1971", "1970", "1969",
                "1968", "1967", "1966", "1965", "1964", "1963", "1962", "1961", "1960", "1959", "1958", "1957", "1956",
                "1955", "1954", "1953", "1952", "1951", "1950", "1949", "1948", "1947", "1946", "1945", "1944", "1943",
                "1942", "1941", "1940", "1939", "1938", "1937", "1936", "1935", "1934", "1933", "1932", "1931", "1930",
                "1929", "1928", "1927", "1926", "1925", "1924", "1923", "1922", "1921", "1920", "1919", "1918", "1917",
                "1916", "1915", "1914", "1913", "1912", "1911", "1910", "1909", "1908", "1907", "1906", "1905", "1904",
                "1903", "1902", "1901", "1900" }));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(
                        layout.createSequentialGroup().addGap(187, 187, 187).addComponent(btsubmit)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btreset)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btcancel).addContainerGap(239, Short.MAX_VALUE))
                .addGroup(
                        layout.createSequentialGroup().addContainerGap().addComponent(lbcompanyname)
                                .addContainerGap(548, Short.MAX_VALUE))
                .addGroup(
                        layout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(
                                        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(
                                                        layout.createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addGroup(
                                                                        layout.createSequentialGroup()
                                                                                .addGroup(
                                                                                        layout.createParallelGroup(
                                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                                .addGroup(
                                                                                                        layout.createSequentialGroup()
                                                                                                                .addGroup(
                                                                                                                        layout.createParallelGroup(
                                                                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                                                                .addGroup(
                                                                                                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                                                                                                        layout.createSequentialGroup()
                                                                                                                                                .addComponent(
                                                                                                                                                        lbpassword)
                                                                                                                                                .addPreferredGap(
                                                                                                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                                                                                                        43,
                                                                                                                                                        Short.MAX_VALUE)
                                                                                                                                                .addGroup(
                                                                                                                                                        layout.createParallelGroup(
                                                                                                                                                                javax.swing.GroupLayout.Alignment.LEADING,
                                                                                                                                                                false)
                                                                                                                                                                .addComponent(
                                                                                                                                                                        txtloginname,
                                                                                                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                                                                                                        213,
                                                                                                                                                                        Short.MAX_VALUE)
                                                                                                                                                                .addComponent(
                                                                                                                                                                        pwfile)
                                                                                                                                                                .addComponent(
                                                                                                                                                                        cbbgroup,
                                                                                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                                                                                                .addComponent(
                                                                                                                                                                        pwcheck)
                                                                                                                                                                .addComponent(
                                                                                                                                                                        txtname,
                                                                                                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                                                                                                        213,
                                                                                                                                                                        Short.MAX_VALUE)
                                                                                                                                                                .addComponent(
                                                                                                                                                                        ttcompanyname,
                                                                                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                                                                                        224,
                                                                                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                                                                                                                .addGroup(
                                                                                                                                        layout.createSequentialGroup()
                                                                                                                                                .addComponent(
                                                                                                                                                        lbage)
                                                                                                                                                .addGap(70,
                                                                                                                                                        70,
                                                                                                                                                        70)
                                                                                                                                                .addComponent(
                                                                                                                                                        cbbngay,
                                                                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                                                                                .addPreferredGap(
                                                                                                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                                                                                                .addComponent(
                                                                                                                                                        cbbthang,
                                                                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                                                                                .addPreferredGap(
                                                                                                                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                                                                                                                .addComponent(
                                                                                                                                                        cbbnam,
                                                                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                                                                                .addPreferredGap(
                                                                                                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                                                                                                        54,
                                                                                                                                                        Short.MAX_VALUE)))
                                                                                                                .addGap(54,
                                                                                                                        54,
                                                                                                                        54))
                                                                                                .addGroup(
                                                                                                        layout.createSequentialGroup()
                                                                                                                .addComponent(
                                                                                                                        lbgroupname)
                                                                                                                .addPreferredGap(
                                                                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                                                                        257,
                                                                                                                        Short.MAX_VALUE))
                                                                                                .addComponent(
                                                                                                        lbloginname))
                                                                                .addPreferredGap(
                                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                                                .addComponent(lbname))
                                                .addGroup(
                                                        layout.createSequentialGroup()
                                                                .addComponent(jLabel1)
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                                .addGroup(
                                        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(
                                                        layout.createSequentialGroup()
                                                                .addGroup(
                                                                        layout.createParallelGroup(
                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                .addComponent(lbaddress)
                                                                                .addComponent(lbcmnd)
                                                                                .addComponent(lbsex))
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                                .addGroup(
                                                                        layout.createParallelGroup(
                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                .addComponent(
                                                                                        cbbsex,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                .addGroup(
                                                                                        layout.createParallelGroup(
                                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                                .addComponent(
                                                                                                        txtcmnd,
                                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                                        185,
                                                                                                        Short.MAX_VALUE)
                                                                                                .addComponent(
                                                                                                        txtaddress,
                                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                                        185,
                                                                                                        Short.MAX_VALUE))))
                                                .addGroup(
                                                        layout.createSequentialGroup()
                                                                .addGroup(
                                                                        layout.createParallelGroup(
                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                .addComponent(lbemail)
                                                                                .addComponent(lbphone))
                                                                .addGap(19, 19, 19)
                                                                .addGroup(
                                                                        layout.createParallelGroup(
                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                .addComponent(
                                                                                        txtphone,
                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                        185, Short.MAX_VALUE)
                                                                                .addComponent(
                                                                                        txtemail,
                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                        185, Short.MAX_VALUE))))
                                .addGap(29, 29, 29)));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                layout.createSequentialGroup()
                        .addContainerGap(17, Short.MAX_VALUE)
                        .addGroup(
                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(lbgroupname)
                                        .addComponent(lbsex)
                                        .addComponent(cbbgroup, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(cbbsex, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(
                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(lbcmnd)
                                        .addComponent(txtcmnd, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(lbloginname)
                                        .addComponent(txtloginname, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(
                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(lbaddress)
                                        .addComponent(txtaddress, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(pwfile, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(lbpassword))
                        .addGap(18, 18, 18)
                        .addGroup(
                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(lbphone)
                                        .addComponent(txtphone, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel1)
                                        .addComponent(pwcheck, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(
                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(
                                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(lbemail)
                                                        .addComponent(txtemail, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(
                                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(lbname)
                                                        .addComponent(txtname, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(18, 18, 18)
                        .addGroup(
                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(lbcompanyname)
                                        .addComponent(ttcompanyname, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(24, 24, 24)
                        .addGroup(
                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(
                                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(cbbngay, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(lbage)
                                                        .addComponent(cbbthang, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(cbbnam, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(
                                                layout.createSequentialGroup()
                                                        .addGap(87, 87, 87)
                                                        .addGroup(
                                                                layout.createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.BASELINE)
                                                                        .addComponent(btsubmit).addComponent(btreset)
                                                                        .addComponent(btcancel)))).addGap(31, 31, 31)));

        pack();
    }

    public static void main(String args[]) {

        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(InsertAccount.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(InsertAccount.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(InsertAccount.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(InsertAccount.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        }

        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                InsertAccount dialog = new InsertAccount(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

}
